//
//  HZPeiziAddMoneyCell.m
//  Stock_Stategy
//
//  Created by MayerF on 2017/12/12.
//  Copyright © 2017年 MayerF. All rights reserved.
//

#import "HZPeiziAddMoneyCell.h"

@interface HZPeiziAddMoneyCell()
@property (nonatomic, strong)UILabel *pOneLabel;
@property (nonatomic, strong)UILabel *pTwoLabel;
@property (nonatomic, strong)UILabel *pThreeLabel;
@property (nonatomic, strong)UILabel *pFourLabel;
@end

@implementation HZPeiziAddMoneyCell

+ (HZPeiziAddMoneyCell *)cellTableView:(UITableView *)tableView
                                          indexPath:(NSIndexPath *)indexPath
                                          cellModel:(HZPeiziMoneyOutListModel *)cellModel
{
    static NSString *ID = @"peizi_addMoneyCell";
    HZPeiziAddMoneyCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[HZPeiziAddMoneyCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        [cell p_commonInit];
        [cell p_initConstraints];
    }
    [cell p_updateDataWithmodel:cellModel indexPath:indexPath];
    
    return cell;
}

- (void)p_commonInit
{
    _pOneLabel = [UILabel new];
    _pTwoLabel = [UILabel new];
    _pThreeLabel = [UILabel new];
    _pFourLabel = [UILabel new];
    
    _pOneLabel.textAlignment = _pTwoLabel.textAlignment =
    _pThreeLabel.textAlignment = _pFourLabel.textAlignment = NSTextAlignmentCenter;
    _pOneLabel.font = _pTwoLabel.font =
    _pThreeLabel.font = _pFourLabel.font = [UIFont systemFontOfSize:14];
}

- (void)p_initConstraints
{
    [self.contentView addSubview:_pOneLabel];
    [self.contentView addSubview:_pTwoLabel];
    [self.contentView addSubview:_pThreeLabel];
    [self.contentView addSubview:_pFourLabel];
    
    [_pOneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.mas_equalTo(self);
        make.left.mas_equalTo(self);
        make.right.mas_equalTo(_pTwoLabel.mas_left);
    }];
    [_pTwoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.mas_equalTo(_pOneLabel);
        make.right.mas_equalTo(_pThreeLabel.mas_left);
    }];
    [_pThreeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.mas_equalTo(_pTwoLabel);
        make.right.mas_equalTo(_pFourLabel.mas_left);
    }];
    [_pFourLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.mas_equalTo(_pThreeLabel);
        make.right.mas_equalTo(self);
        make.width.mas_equalTo(@[_pOneLabel, _pTwoLabel, _pThreeLabel]);
    }];
}

- (void)p_updateDataWithmodel:(HZPeiziMoneyOutListModel *)model indexPath:(NSIndexPath *)indexPath
{
    [self p_cleaOldData];
    [self p_updateNewData:model];
}
- (void)p_updateNewData:(HZPeiziMoneyOutListModel *)model
{
    _pOneLabel.text = model.occur_date;
    _pTwoLabel.text = model.occur_time;
    _pThreeLabel.text = model.occur_balance;
    if ([model.audit_status isEqual:@"0"]) {
        _pFourLabel.text = @"未审核";
    }else if ([model.audit_status isEqual:@"1"]) {
         _pFourLabel.text = @"已通过";
    }else {
         _pFourLabel.text = @"已拒绝";
    }
}
- (void)p_cleaOldData
{
    [_pOneLabel setText:@""];
    [_pTwoLabel setText:@""];
    [_pThreeLabel setText:@""];
    [_pFourLabel setText:@""];
}

@end
